﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NVSecurity.Models;

namespace NVSecurity.Areas.Admin.Controllers
{
    public class AboutController : Controller
    {
        private NVSecurityEntities db = new NVSecurityEntities();
        //
        // GET: /Admin/About/

        public ActionResult Index()
        {
            Setting setting = db.Settings.Where(m => m.Key == "About").FirstOrDefault();
            return View(setting);
        }
        public ActionResult Edit(int id = 0)
        {
            Setting setting = db.Settings.Where(m => m.Key == "About").FirstOrDefault();
            if (setting == null)
            {
                return HttpNotFound();
            }
            return View(setting);
        }

        //
        // POST: /Admin/Training/Edit/5

        [HttpPost, ValidateInput(false)]
        public ActionResult Edit(Setting setting)
        {
            if (ModelState.IsValid)
            {
                db.Entry(setting).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(setting);
        }

    }
}
